<?php
function randstr()
{
    $str = @file_get_contents('ss.txt');
    $str = explode("\n", $str);
    $content = $str[array_rand($str, 1)];
    return $content;
}

function randimg()
{
    $row = @file_get_contents('pic.txt');
    $row = explode("\n", $row);
    shuffle($row);
    $pic = $row[0];
    $pic = trim($pic);
    return $pic;
}

function hitokoto()
{
    $url = 'https://v1.hitokoto.cn/?encode=json'; // 不限定内容类型
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); // 跳过证书检查
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2); // 从证书中检查SSL加密算法是否存在
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET');
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_TIMEOUT, 6);
    $response = curl_exec($ch);
    if ($error = curl_error($ch)) {
        return randstr(); // 如果6s内，一言API调用失败则输出这个默认句子~
    }
    curl_close($ch);
    $array_data = json_decode($response, true);
    $lxtx_content = $array_data['hitokoto']; // 输出格式：经典语句----《语句出处》
    return $lxtx_content;
}

function hitokoto2($t)
{
    $url = 'https://v1.hitokoto.cn/?encode=json?c=' . $t; // 限定内容类型
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); // 跳过证书检查
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2); // 从证书中检查SSL加密算法是否存在
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET');
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_TIMEOUT, 6);
    $response = curl_exec($ch);
    if ($error = curl_error($ch)) {
        return randstr(); // 如果6s内，一言API调用失败则输出这个默认句子~
    }
    curl_close($ch);
    $array_data = json_decode($response, true);
    $lxtx_content = $array_data['hitokoto']; // 输出格式：经典语句----《语句出处》
    return $lxtx_content;
}

function comments_163(){
	$str=curl_get('http://api.qqzzz.net/comments163/api.php?format=text');
	return $str;
}

?>